﻿/* ==============================================================================
 * 功能描述：SkillModule  
 * 
 * 创 建 者：郑镇泉
 * 
 * 创建日期：2016/4/14 14:16:27
 * ==============================================================================*/
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using ZZQFrameWork;

/// <summary>
/// 技能效果类型
/// </summary>
public enum Enum_SkillEffectType
{
    Attack,Def
}

/// <summary>
/// 技能消耗类型
/// </summary>
public enum Enum_SkillConsumeType
{
    Hp,Mp
}

/// <summary>
/// 技能效果数据
/// </summary>
public class SkillEffectData
{
    /// <summary>
    /// 效果类型
    /// </summary>
    public Enum_SkillEffectType effectType;

    /// <summary>
    /// 效果值
    /// </summary>
    public int effectValue;

    public SkillEffectData(Enum_SkillEffectType type, int value)
    {
        effectType = type;
        effectValue = value;
    }
}

/// <summary>
/// 技能消耗数据
/// </summary>
public class SkillConsumeData
{
    /// <summary>
    /// 消耗类型
    /// </summary>
    public Enum_SkillConsumeType consumeType;

    /// <summary>
    /// 消耗值
    /// </summary>
    public int consumeValue;

    public SkillConsumeData(Enum_SkillConsumeType type,int value)
    {
        consumeType = type;
        consumeValue = value;
    }
}

public class SkillVO
{
    public int id;//技能Id
    public string name;//技能名
    public string icon;//技能图标
    public string des;//描述
    public float range;//范围
    //public List<SkillEffectData> effectDataList=new List<SkillEffectData>();
    //public List<SkillConsumeData> consumeDataList=new List<SkillConsumeData>();
    public SkillEffectData effectData;//效果数据
    public SkillConsumeData consumeData;//消耗数据
    public float coldTime;//冷却时间
    public int lvNeed;//人物等级需求
    public int lv;//技能等级
    private bool isCold = false;//是否处于冷却

    public bool IsCold
    {
        get { return isCold; }
        set
        {
            isCold = value;
            if (isCold)
            {
                TimerHeap.AddTimer((uint)coldTime*1000, 0, () =>
                {
                    isCold = false;
                });
            }
        }
    }

    public SkillVO(int id)
    {
        this.id = id;

        #region 旧配置

        //SkillConfig config = SkillConfig.get(id);//根据id从技能配置表中找到该技能信息
        //name = config.Name;
        //icon = config.Icon;
        //des = config.Des;
        //range = config.Range;
        //effectData=new SkillEffectData((Enum_SkillEffectType)config.EffectType,config.EffectValue);
        //consumeData=new SkillConsumeData((Enum_SkillConsumeType)config.ConsumeType,config.ConsumeValue);
        //coldTime = config.ColdTime;
        //lvNeed = config.LvNeed;

        #endregion

        SkillConfigSkill skill = SkillConfigProvider.Instance.GetSkillById(id);
        id = int.Parse(skill.id);
        name = skill.name;
        icon = skill.icon;
        des = skill.des;
        range = float.Parse(skill.range);
        coldTime = float.Parse(skill.coldTime);
        effectData=new SkillEffectData((Enum_SkillEffectType)int.Parse(skill.effectType),int.Parse(skill.EffectValue));
        consumeData=new SkillConsumeData((Enum_SkillConsumeType)int.Parse(skill.consumeType),int.Parse(skill.consumeValue));
        lvNeed = int.Parse(skill.lvNeed);
        lv = 0;
    }

}

public class SkillModule : BaseModule
{
    /// <summary>
    /// 角色拥有的技能集合
    /// </summary>
    public List<SkillVO> skillVOList=new List<SkillVO>(); 

    public SkillModule()
    {
        AutoRegister = true;

        #region 测试
        #endregion

    }
}